package git.bankview.sl.report;

import net.sf.jasperreports.engine.JRParameter;
import net.sf.jasperreports.engine.JRExpression;
import org.apache.log4j.Logger;

public class ReportParameter
	implements java.io.Serializable
{
	private static Logger log = Logger.getLogger(ReportParameter.class);

	private JRParameter m_oJRParam = null;
	//private String m_oRunTimeValue = null;
	
	public ReportParameter(JRParameter p)
	{
		m_oJRParam = p;
	}
	
	public java.lang.String getDescription()
	{
		return encode(m_oJRParam.getDescription());
	}

	public java.lang.String getQuotableDescription()
	{
		//return laya.semi.process.CompilerUtil.toRequotableString(getDescription());
		return getDescription();
	}
	
	public java.lang.String getName()
	{
		return m_oJRParam.getName();
	}
	
	public java.lang.String getNameKey()
	{
		String pname = getName();
		
		if (ReportCommon.GRP_SCHD_DATE.equals(pname)) return "ReportCommon.GRP_SCHD_DATE";
		else if (ReportCommon.GRP_DEPT_NO.equals(pname)) return "ReportCommon.GRP_DEPT_NO";
		else if (ReportCommon.GRP_DEPT_NOS.equals(pname)) return "ReportCommon.GRP_DEPT_NOS";
		else if (ReportCommon.GRP_USER_ID.equals(pname)) return "ReportCommon.GRP_USER_ID";
		else if (ReportCommon.GRP_TERM_FROM.equals(pname)) return "ReportCommon.GRP_TERM_FROM";
		else if (ReportCommon.JR_IS_IGNORE_PAGINATION.equals(pname)) return "ReportCommon.JR_IS_IGNORE_PAGINATION";
		else if (ReportCommon.GRP_FORCE_PAGINATION.equals(pname)) return "ReportCommon.GRP_FORCE_PAGINATION";
		
		return null;
	}
	
	public java.lang.Class getValueClass()
	{
		return m_oJRParam.getValueClass();
	}
	       
	public java.lang.String getValueClassName()
	{
		return m_oJRParam.getValueClassName();
	}
	       
	public boolean isForPrompting()
	{
		return m_oJRParam.isForPrompting();
	}

	public boolean isSystemDefined()
	{
		return m_oJRParam.isSystemDefined();
	}
	
	public java.lang.String getDefaultValueText()
	{
		JRExpression expr = m_oJRParam.getDefaultValueExpression();
		return (null != expr ? expr.getText() : null);
	}
	
	private String m_defaultInputText = null;
	
	public void setDefaultInputText(String txt)
	{
		m_defaultInputText = txt;
	}
	
	public java.lang.String getDefaultInputText()
	{
		return m_defaultInputText;
	}
	/*
	public void setRunTimeValue(String val)
	{
		m_oRunTimeValue = val;
	}
	
	public String getRunTimeValue()
	{
		return m_oRunTimeValue;
	}
	*/
	String encode(String val)
	{
		if (null == val || 0 == val.length())
			return val;
		
		try
		{
			return new String(val.getBytes("gbk"), "iso8859_1");
		}
		catch(Exception e)
		{
			log.warn("encode String err: ", e);
			return val;
		}
	}
}
